#!/bin/sh
# PSsuwaveform1 - Demo shell script for program SUWAVEFORM
# Author: Nils Maercklin, 2006
#
# This demo shell script shows the generation of AKB or Ricker wavelets
# with different maximum or peak frequencies (PS plots).


# Create empty wavelet output files:
> akb_wavelet.su
> ricker_wavelet.su

# Generate AKB and zero-phase Ricker wavelets with different
# maximum or peak frequency fpeak, normalize by maximum amplitude,
# and store fpeak in header otrav for plotting:

for fpeak in 5 10 15 20 25 30
do
    # AKB wavelet:
    suwaveform type=akb fpeak=$fpeak ns=201 \
    | sushw key=otrav a=$fpeak \
    | sugain qbal=1 >> akb_wavelet.su
    
    # Ricker wavelet:
    suwaveform type=ricker1 fpeak=$fpeak ns=201 \
    | sushw key=otrav a=$fpeak \
    | sugain qbal=1 >> ricker_wavelet.su

done

# PS plot of AKB wavelets (key otrav = fpeak):
supswigp <akb_wavelet.su key=otrav title="wavelet type=akb" \
    grid1=dot xcur=0.75 linewidth=0 label1=" time (s)" \
    label2="maximum frequency fpeak (Hz)" >akb_wavelet.ps


# PS plot of Ricker wavelets
# (key otrav = fpeak; maximum amplitude at t=0.0 seconds):
sushift <ricker_wavelet.su \
| supswigp key=otrav title="wavelet type=ricker1" \
    grid1=dot xcur=0.75 linewidth=0 label1=" time (s)" \
    label2="peak frequency fpeak (Hz)" >ricker_wavelet.ps

# Merge the two PS plots onto one page:
merge2 akb_wavelet.ps ricker_wavelet.ps > wavelets.ps


# User info:
cat <<EOF >> /dev/stderr
 Files created by demo PSsuwaveform1:

 akb_wavelet.su        data file 1, AKB wavelets with different fpeak
 ricker_wavelet.su     data file 2, Ricker wavelets with different fpeak

 akb_wavelet.ps        PS plot of data file 1
 ricker_wavelet.ps     PS plot of data file 2
 wavelets.ps           both PS plots merged onto one page

EOF

exit 0
